package com.tianji.medical.service.Impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tianji.medical.mapper.MedicationSendLogMapper;
import com.tianji.medical.pojo.MedicationSendLog;
import com.tianji.medical.pojo.PatientMedication;
import com.tianji.medical.service.MedicationSendLogService;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 陈佳
 * @since 2024-10-15
 */
@Service
public class MedicationSendLogServiceImpl extends ServiceImpl<MedicationSendLogMapper, MedicationSendLog> implements MedicationSendLogService {

    @Async("saveAsyncLogExecutor")
    @Override
    public void logFailedSend(PatientMedication patientMedication, String message) {
        MedicationSendLog medicationSendLog = new MedicationSendLog();
        BeanUtils.copyProperties(patientMedication, medicationSendLog,"id");
        medicationSendLog.setStatus("FAILED");
        medicationSendLog.setErrorMessage(message);
        this.save(medicationSendLog);
    }
}
